import {
	UploadD
} from '../api/system'

class MyUploadAdapter {
	constructor(loader) {
		this.loader = loader;
	}

	async upload() {
		var formData = new FormData();
		var file = await this.loader.file;
		formData.append("file", file);
		console.log(formData.get('file'));
		var res = await UploadD(formData)


		// 后台返回数据：
		// {"code":0,"msg":"success","data":{"url":"/upload/struts2.jpeg"}}

		// 方法返回数据格式： {default: "url"}
		return {
			default: res.data
		};
	}
}

export default MyUploadAdapter;
